#include "graphMatrix.h"

int main ()
{
    PGraphMatrix graph;
    PVertex vi, vj, vk;
    VexType value;
    
    int i, j, n;
    AdjType ** arcs;   
    
    scanf("%d", &n);
    
    arcs = (AdjType **) malloc(sizeof(AdjType *)*n);
    if (arcs != NULL)
    {
        for (i = 0; i < n; i++)
        {
            arcs[i] = (AdjType *) malloc(sizeof(AdjType)*n);
        }
        
        for (i = 0; i < n; i++)
        {
            for (j = 0; j < n; j++)
            {
                scanf("%d", &arcs[i][j]);
            }
        }
/*
        for (i = 0; i < n; i++)
        {
            for (j = 0; j < n; j++)
            {
                printf("%d ", arcs[i][j]);
            }
            printf("\n");
        }
*/
        
        graph = createGraph(n, arcs);
        print(graph);

	/*
	value = 'c';
	vi = findVertex(graph, value);

	if (hasVertex(graph, vi))
	{
		printVertex(graph, vi);
	}
	*/

	vi = firstVertex(graph);
	if (hasVertex(graph, vi))
	{
		printVertex(graph, vi);
	}


	/*
	value = 'b';
	vi = findVertex(graph, value);

	value = 'a';
	vj = findVertex(graph, value);

	vk = nextAdjacent(graph, vi, vj);

	if (vk != NULL)
	{
		printf("Next adjacent of %c -> %c => %c\n", vi->v, vj->v, vk->v);
		printVertex(graph, vk);
	}
	*/

	//dfsGraph(graph, vi);

	dftGraph(graph);

	/*
	vj = nextVertex(graph, vi);

	if (hasVertex(graph, vj))
	{
		printVertex(graph, vj);
	}
	*/

	/*
	if (deleteEdge(graph, vi, vj) > 0)
	{
		printf("Edge deleted!!!!\n");
        	print(graph);
	}

	if (findEdge(graph, vi, vj) > 0)
	{
		printf("Edge founded!!!!\n");
		printf("Source Vertex is: \n");
		printVertex(graph, vi);
		printf("Dest Vertex is: \n");
		printVertex(graph, vj);
	}
	else
	{
		printf("Edge not founded!!!!\n");
		printf("Source Vertex is: \n");
		printVertex(graph, vi);
		printf("Dest Vertex is: \n");
		printVertex(graph, vj);
	}

	if (addEdge(graph, vi, vj) > 0)
	{
		printf("Edge added!!!!\n");
        	print(graph);
	}

	if (findEdge(graph, vi, vj) > 0)
	{
		printf("Edge founded!!!!\n");
		printf("Source Vertex is: \n");
		printVertex(graph, vi);
		printf("Dest Vertex is: \n");
		printVertex(graph, vj);
	}
	else
	{
		printf("Edge not founded!!!!\n");
		printf("Source Vertex is: \n");
		printVertex(graph, vi);
		printf("Dest Vertex is: \n");
		printVertex(graph, vj);
	}

	*/
	destroyGraph(&graph);

        for (i = 0; i < n; i++)
        {
            if (arcs[i] != NULL)
	    {
		    free (arcs[i]);
	    }
        }
	free (arcs);
    }

    return 0;
}
